EmbDev.net

Forum: FPGA, VHDL & Verilog Storing char application


von Junior H. (Company: University) (junior_hpc)


Rate this post
useful
not useful
Hello. I want to develop an application that is able to get and store 
two input values, swap from lower case to upper case only the first 
value and finally output the two stored values. E.g.: if the input 
string is "john", then the output string should be "JoHn". The 
application should get "j" from user_w_write_8_data and store it into 
my_buffer_a, swap "j" into "J", then get "o" store it into my_buffer_b, 
then output "J", then output "o". After that the application should get 
"h" from user_w_write_8_data,  swap "h" into "H", and store it into 
my_buffer_a, then get "n" store it into my_buffer_b, then output "H", 
then output "n". Basically, the application should store two characters, 
swap the first one and then output these two, store other two 
characters, swap the first one and then output these two characters etc. 
The problem of my application does not swap lower to upper characters 
that is stored into my_buffer_a. Instead of outputing "JoHn", my 
application outputs "john". It seems like that my application does not 
go into the first if statement (if (counter=0) then...), but I am asking 
to myself how it is possible that the application outputs data if does 
not go into if (counter=0) then... Any hint?

Thanks.

Here the code:
1
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.std_logic_unsigned.all;
4
use ieee.numeric_std.all;
5
6
entity xillydemo is
7
  port (
8
    PCIE_PERST_B_LS : IN std_logic;
9
    PCIE_REFCLK_N : IN std_logic;
10
    PCIE_REFCLK_P : IN std_logic;
11
    PCIE_RX_N : IN std_logic_vector(3 DOWNTO 0);
12
    PCIE_RX_P : IN std_logic_vector(3 DOWNTO 0);
13
    GPIO_LED : OUT std_logic_vector(3 DOWNTO 0);
14
    PCIE_TX_N : OUT std_logic_vector(3 DOWNTO 0);
15
    PCIE_TX_P : OUT std_logic_vector(3 DOWNTO 0));
16
end xillydemo;
17
18
architecture sample_arch of xillydemo is
19
  component xillybus
20
    port (
21
      PCIE_PERST_B_LS : IN std_logic;
22
      PCIE_REFCLK_N : IN std_logic;
23
      PCIE_REFCLK_P : IN std_logic;
24
      PCIE_RX_N : IN std_logic_vector(3 DOWNTO 0);
25
      PCIE_RX_P : IN std_logic_vector(3 DOWNTO 0);
26
      GPIO_LED : OUT std_logic_vector(3 DOWNTO 0);
27
      PCIE_TX_N : OUT std_logic_vector(3 DOWNTO 0);
28
      PCIE_TX_P : OUT std_logic_vector(3 DOWNTO 0);
29
      bus_clk : OUT std_logic;
30
      quiesce : OUT std_logic;
31
      user_r_mem_8_rden : OUT std_logic;
32
      user_r_mem_8_empty : IN std_logic;
33
      user_r_mem_8_data : IN std_logic_vector(7 DOWNTO 0);
34
      user_r_mem_8_eof : IN std_logic;
35
      user_r_mem_8_open : OUT std_logic;
36
      user_w_mem_8_wren : OUT std_logic;
37
      user_w_mem_8_full : IN std_logic;
38
      user_w_mem_8_data : OUT std_logic_vector(7 DOWNTO 0);
39
      user_w_mem_8_open : OUT std_logic;
40
      user_mem_8_addr : OUT std_logic_vector(4 DOWNTO 0);
41
      user_mem_8_addr_update : OUT std_logic;
42
      user_r_read_32_rden : OUT std_logic;
43
      user_r_read_32_empty : IN std_logic;
44
      user_r_read_32_data : IN std_logic_vector(31 DOWNTO 0);
45
      user_r_read_32_eof : IN std_logic;
46
      user_r_read_32_open : OUT std_logic;
47
      user_r_read_8_rden : OUT std_logic;
48
      user_r_read_8_empty : IN std_logic;
49
      user_r_read_8_data : IN std_logic_vector(7 DOWNTO 0);
50
      user_r_read_8_eof : IN std_logic;
51
      user_r_read_8_open : OUT std_logic;
52
      user_w_write_32_wren : OUT std_logic;
53
      user_w_write_32_full : IN std_logic;
54
      user_w_write_32_data : OUT std_logic_vector(31 DOWNTO 0);
55
      user_w_write_32_open : OUT std_logic;
56
      user_w_write_8_wren : OUT std_logic;
57
      user_w_write_8_full : IN std_logic;
58
      user_w_write_8_data : OUT std_logic_vector(7 DOWNTO 0);
59
      user_w_write_8_open : OUT std_logic);
60
  end component;
61
62
  component fifo_8x2048
63
    port (
64
      clk: IN std_logic;
65
      srst: IN std_logic;
66
      din: IN std_logic_VECTOR(7 downto 0);
67
      wr_en: IN std_logic;
68
      rd_en: IN std_logic;
69
      dout: OUT std_logic_VECTOR(7 downto 0);
70
      full: OUT std_logic;
71
      empty: OUT std_logic);
72
  end component;
73
74
  component fifo_32x512
75
    port (
76
      clk: IN std_logic;
77
      srst: IN std_logic;
78
      din: IN std_logic_VECTOR(31 downto 0);
79
      wr_en: IN std_logic;
80
      rd_en: IN std_logic;
81
      dout: OUT std_logic_VECTOR(31 downto 0);
82
      full: OUT std_logic;
83
      empty: OUT std_logic);
84
  end component;
85
86
-- Synplicity black box declaration
87
  attribute syn_black_box : boolean;
88
  attribute syn_black_box of fifo_32x512: component is true;
89
  attribute syn_black_box of fifo_8x2048: component is true;
90
91
  type demo_mem is array(0 TO 31) of std_logic_vector(7 DOWNTO 0);
92
  signal demoarray : demo_mem;
93
  
94
  signal bus_clk :  std_logic;
95
  signal quiesce : std_logic;
96
97
  signal reset_8 : std_logic;
98
  signal reset_32 : std_logic;
99
100
  signal ram_addr : integer range 0 to 31;
101
  
102
  signal user_r_mem_8_rden :  std_logic;
103
  signal user_r_mem_8_empty :  std_logic;
104
  signal user_r_mem_8_data :  std_logic_vector(7 DOWNTO 0);
105
  signal user_r_mem_8_eof :  std_logic;
106
  signal user_r_mem_8_open :  std_logic;
107
  signal user_w_mem_8_wren :  std_logic;
108
  signal user_w_mem_8_full :  std_logic;
109
  signal user_w_mem_8_data :  std_logic_vector(7 DOWNTO 0);
110
  signal user_w_mem_8_open :  std_logic;
111
  signal user_mem_8_addr :  std_logic_vector(4 DOWNTO 0);
112
  signal user_mem_8_addr_update :  std_logic;
113
  signal user_r_read_32_rden :  std_logic;
114
  signal user_r_read_32_empty :  std_logic;
115
  signal user_r_read_32_data :  std_logic_vector(31 DOWNTO 0);
116
  signal user_r_read_32_eof :  std_logic;
117
  signal user_r_read_32_open :  std_logic;
118
  signal user_r_read_8_rden :  std_logic;
119
  signal user_r_read_8_empty :  std_logic;
120
  signal user_r_read_8_data :  std_logic_vector(7 DOWNTO 0);
121
  signal user_r_read_8_eof :  std_logic;
122
  signal user_r_read_8_open :  std_logic;
123
  signal user_w_write_32_wren :  std_logic;
124
  signal user_w_write_32_full :  std_logic;
125
  signal user_w_write_32_data :  std_logic_vector(31 DOWNTO 0);
126
  signal user_w_write_32_open :  std_logic;
127
  signal user_w_write_8_wren :  std_logic;
128
  signal user_w_write_8_full :  std_logic;
129
  signal user_w_write_8_data :  std_logic_vector(7 DOWNTO 0);
130
  signal user_w_write_8_open :  std_logic;
131
132
begin
133
  xillybus_ins : xillybus
134
    port map (
135
      -- Ports related to /dev/xillybus_mem_8
136
      -- FPGA to CPU signals:
137
      user_r_mem_8_rden => user_r_mem_8_rden,
138
      user_r_mem_8_empty => user_r_mem_8_empty,
139
      user_r_mem_8_data => user_r_mem_8_data,
140
      user_r_mem_8_eof => user_r_mem_8_eof,
141
      user_r_mem_8_open => user_r_mem_8_open,
142
      -- CPU to FPGA signals:
143
      user_w_mem_8_wren => user_w_mem_8_wren,
144
      user_w_mem_8_full => user_w_mem_8_full,
145
      user_w_mem_8_data => user_w_mem_8_data,
146
      user_w_mem_8_open => user_w_mem_8_open,
147
      -- Address signals:
148
      user_mem_8_addr => user_mem_8_addr,
149
      user_mem_8_addr_update => user_mem_8_addr_update,
150
151
      -- Ports related to /dev/xillybus_read_32
152
      -- FPGA to CPU signals:
153
      user_r_read_32_rden => user_r_read_32_rden,
154
      user_r_read_32_empty => user_r_read_32_empty,
155
      user_r_read_32_data => user_r_read_32_data,
156
      user_r_read_32_eof => user_r_read_32_eof,
157
      user_r_read_32_open => user_r_read_32_open,
158
159
      -- Ports related to /dev/xillybus_read_8
160
      -- FPGA to CPU signals:
161
      user_r_read_8_rden => user_r_read_8_rden,
162
      user_r_read_8_empty => user_r_read_8_empty,
163
      user_r_read_8_data => user_r_read_8_data,
164
      user_r_read_8_eof => user_r_read_8_eof,
165
      user_r_read_8_open => user_r_read_8_open,
166
167
      -- Ports related to /dev/xillybus_write_32
168
      -- CPU to FPGA signals:
169
      user_w_write_32_wren => user_w_write_32_wren,
170
      user_w_write_32_full => user_w_write_32_full,
171
      user_w_write_32_data => user_w_write_32_data,
172
      user_w_write_32_open => user_w_write_32_open,
173
174
      -- Ports related to /dev/xillybus_write_8
175
      -- CPU to FPGA signals:
176
      user_w_write_8_wren => user_w_write_8_wren,
177
      user_w_write_8_full => user_w_write_8_full,
178
      user_w_write_8_data => user_w_write_8_data,
179
      user_w_write_8_open => user_w_write_8_open,
180
181
      -- General signals
182
      PCIE_PERST_B_LS => PCIE_PERST_B_LS,
183
      PCIE_REFCLK_N => PCIE_REFCLK_N,
184
      PCIE_REFCLK_P => PCIE_REFCLK_P,
185
      PCIE_RX_N => PCIE_RX_N,
186
      PCIE_RX_P => PCIE_RX_P,
187
      GPIO_LED => GPIO_LED,
188
      PCIE_TX_N => PCIE_TX_N,
189
      PCIE_TX_P => PCIE_TX_P,
190
      bus_clk => bus_clk,
191
      quiesce => quiesce
192
      );
193
194
--  A simple inferred RAM
195
196
  ram_addr <= conv_integer(user_mem_8_addr);
197
  
198
  process (bus_clk)
199
        
200
            variable counter : integer := 0;
201
            variable my_buffer_a :  std_logic_vector(7 downto 0) := (others => '0');
202
            variable my_buffer_b :  std_logic_vector(7 downto 0) := (others => '0');
203
            
204
            begin 
205
              
206
              if (bus_clk'event and bus_clk = '1') then
207
                 if (counter=0) then --push data from user_w_write_8_data to my_buffer_a
208
                    my_buffer_a := user_w_write_8_data;
209
                    my_buffer_a(5) := not my_buffer_a(5);
210
                    counter := 1;
211
                 elsif (counter = 1) then --push data from user_w_write_8_data to my_buffer_b
212
                    my_buffer_b := user_w_write_8_data;
213
                    counter := 2;
214
                 elsif (counter = 2) then --pull data from my_buffer_a to din
215
                    user_r_mem_8_data <= my_buffer_a;
216
                    counter := 3;
217
                 elsif (counter = 3) then --pull data from my_buffer_b to din
218
                    user_r_mem_8_data <= my_buffer_b;
219
                    counter := 0;
220
                 end if;
221
             end if;
222
         end process;
223
224
  user_r_mem_8_empty <= '0';
225
  user_r_mem_8_eof <= '0';
226
  user_w_mem_8_full <= '0';
227
228
--  32-bit loopback
229
230
  fifo_32 : fifo_32x512
231
    port map(
232
      clk        => bus_clk,
233
      srst       => reset_32,
234
      din        => user_w_write_32_data,
235
      wr_en      => user_w_write_32_wren,
236
      rd_en      => user_r_read_32_rden,
237
      dout       => user_r_read_32_data,
238
      full       => user_w_write_32_full,
239
      empty      => user_r_read_32_empty
240
      );
241
242
  reset_32 <= not (user_w_write_32_open or user_r_read_32_open);
243
244
  user_r_read_32_eof <= '0';
245
  
246
--  8-bit loopback
247
248
  fifo_8 : fifo_8x2048
249
    port map(
250
      clk        => bus_clk,
251
      srst       => reset_8,
252
      din        => user_w_write_8_data,
253
      wr_en      => user_w_write_8_wren,
254
      rd_en      => user_r_read_8_rden,
255
      dout       => user_r_read_8_data,
256
      full       => user_w_write_8_full,
257
      empty      => user_r_read_8_empty
258
      );
259
260
    reset_8 <= not (user_w_write_8_open or user_r_read_8_open);
261
262
    user_r_read_8_eof <= '0';
263
  
264
end sample_arch;

von S. N. (higgns)


Rate this post
useful
not useful
The code looks fine. In your previous thread you were writing into the 
FIFO instead of mem_8_data though.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.