EmbDev.net

Forum: FPGA, VHDL & Verilog Is this nonesense?


von Julian M. (Company: Relevant Technologies Ltd) (geoffreym)


Rate this post
useful
not useful
Hi

I have multiple clocked processes, all of which must access the same 
resources in my ip block. I often end up with something like this:
1
process(ps_reset_cir_b, reset_cir_cmd_rqst, reset_cir_cmd_out, 
2
        ps_init_cir_b,  init_cir_cmd_rqst,  init_cir_cmd_out,  init_cir_arg_out, 
3
        ps_rx_row_b,    rx_row_cmd_rqst,    rx_row_cmd_out,     
4
        ps_tx_max_b,    tx_max_cmd_rqst,    tx_max_cmd_out,                     tx_max_tready,
5
        ps_tx_cir_b,    tx_cir_cmd_rqst,    tx_cir_cmd_out,    tx_cir_arg_out,  tx_cir_tready,
6
        ps_wr_bram_b,   wr_bram_cmd_rqst,   wr_bram_cmd_out,   wr_bram_arg_out, 
7
        ps_rd_bram_b,   rd_bram_cmd_rqst,   rd_bram_cmd_out,   rd_bram_arg_out, rd_bram_tready,
8
        ps_wr_reg_b,    wr_reg_cmd_rqst,    wr_reg_cmd_out,    wr_reg_arg_out, 
9
        ps_rd_reg_b,    rd_reg_cmd_rqst,    rd_reg_cmd_out,    rd_reg_arg_out,  rd_reg_tready
10
  )
11
begin
12
  if (ps_reset_cir_b = '1') then 
13
    s_axis_cir_tready      <= '0';
14
    cmd_rqst               <= reset_cir_cmd_rqst;   
15
    cmd_out                <= reset_cir_cmd_out;    
16
    arg_out                <= (others=>'0');    
17
  elsif (ps_init_cir_b = '1') then  
18
    s_axis_cir_tready      <= '0';
19
    cmd_rqst               <= init_cir_cmd_rqst;    
20
    cmd_out                <= init_cir_cmd_out;     
21
    arg_out                <= init_cir_arg_out;     
22
  elsif (ps_rx_row_b = '1') then
23
    s_axis_cir_tready      <= '0';
24
    cmd_rqst               <= rx_row_cmd_rqst;      
25
    cmd_out                <= rx_row_cmd_out;       
26
    arg_out                <= (others=>'0');       
27
  elsif (ps_tx_max_b = '1') then
28
    s_axis_cir_tready      <= tx_max_tready;
29
    cmd_rqst               <= tx_max_cmd_rqst;      
30
    cmd_out                <= tx_max_cmd_out;       
31
    arg_out                <= (others=>'0');       
32
  elsif (ps_tx_cir_b = '1') then
33
    s_axis_cir_tready      <= tx_cir_tready;
34
    cmd_rqst               <= tx_cir_cmd_rqst;      
35
    cmd_out                <= tx_cir_cmd_out;       
36
    arg_out                <= tx_cir_arg_out;       
37
  elsif (ps_wr_bram_b = '1') then
38
    s_axis_cir_tready      <= '0';
39
    cmd_rqst               <= wr_bram_cmd_rqst;     
40
    cmd_out                <= wr_bram_cmd_out;      
41
    arg_out                <= wr_bram_arg_out;      
42
  elsif (ps_rd_bram_b = '1') then
43
    s_axis_cir_tready      <= rd_bram_tready;
44
    cmd_rqst               <= rd_bram_cmd_rqst;     
45
    cmd_out                <= rd_bram_cmd_out;      
46
    arg_out                <= rd_bram_arg_out;      
47
  elsif (ps_wr_reg_b = '1') then
48
    s_axis_cir_tready      <= '0';
49
    cmd_rqst               <= wr_reg_cmd_rqst;  
50
    cmd_out                <= wr_reg_cmd_out;   
51
    arg_out                <= wr_reg_arg_out;   
52
  elsif (ps_rd_reg_b = '1') then
53
    s_axis_cir_tready      <= rd_reg_tready;
54
    cmd_rqst               <= rd_reg_cmd_rqst;  
55
    cmd_out                <= rd_reg_cmd_out;   
56
    arg_out                <= rd_reg_arg_out;
57
  else
58
    s_axis_cir_tready      <= '0';
59
    cmd_rqst               <= (others=>'0');  
60
    cmd_out                <= (others=>'0');  
61
    arg_out                <= (others=>'0');
62
  end if;   
63
end process;

Does this look silly? The various bits indicate the process which is 
accessing the mux is active. When all processes are in the idle state, 
the final else is active. The various processes, in this case, are 
servicing requests from the host cpu. The signals on the left are 
interfaces, and each process must use some or all of these.

Best regards
Geoff

von Lothar M. (Company: Titel) (lkmiller) (Moderator)


Rate this post
useful
not useful
Julian M. wrote:
> I have multiple clocked processes
I can't see absolutely no clock there...

> Does this look silly?
No, ist just the way to write the multiplexer in a process. You could do 
it as a concurrent descritpion also.

But the most easy way would be: use VHDL-2008 and write process(all).

Then you could shorten it further on by using default values instead of 
the last "else":
1
process(all)
2
begin
3
  s_axis_cir_tready      <= '0';
4
  cmd_rqst               <= (others=>'0');  
5
  cmd_out                <= (others=>'0');  
6
  arg_out                <= (others=>'0');
7
  if (ps_reset_cir_b = '1') then 
8
    cmd_rqst               <= reset_cir_cmd_rqst;   
9
    cmd_out                <= reset_cir_cmd_out;    
10
  elsif (ps_init_cir_b = '1') then  
11
    cmd_rqst               <= init_cir_cmd_rqst;    
12
    cmd_out                <= init_cir_cmd_out;     
13
    arg_out                <= init_cir_arg_out;     
14
  elsif (ps_rx_row_b = '1') then
15
    cmd_rqst               <= rx_row_cmd_rqst;      
16
    cmd_out                <= rx_row_cmd_out;             
17
  elsif (ps_tx_max_b = '1') then
18
    s_axis_cir_tready      <= tx_max_tready;
19
    cmd_rqst               <= tx_max_cmd_rqst;      
20
    cmd_out                <= tx_max_cmd_out;       
21
  elsif (ps_tx_cir_b = '1') then
22
    s_axis_cir_tready      <= tx_cir_tready;
23
    cmd_rqst               <= tx_cir_cmd_rqst;      
24
    cmd_out                <= tx_cir_cmd_out;       
25
    arg_out                <= tx_cir_arg_out;       
26
  elsif (ps_wr_bram_b = '1') then
27
    cmd_rqst               <= wr_bram_cmd_rqst;     
28
    cmd_out                <= wr_bram_cmd_out;      
29
    arg_out                <= wr_bram_arg_out;      
30
  elsif (ps_rd_bram_b = '1') then
31
    s_axis_cir_tready      <= rd_bram_tready;
32
    cmd_rqst               <= rd_bram_cmd_rqst;     
33
    cmd_out                <= rd_bram_cmd_out;      
34
    arg_out                <= rd_bram_arg_out;      
35
  elsif (ps_wr_reg_b = '1') then
36
    cmd_rqst               <= wr_reg_cmd_rqst;  
37
    cmd_out                <= wr_reg_cmd_out;   
38
    arg_out                <= wr_reg_arg_out;   
39
  elsif (ps_rd_reg_b = '1') then
40
    s_axis_cir_tready      <= rd_reg_tready;
41
    cmd_rqst               <= rd_reg_cmd_rqst;  
42
    cmd_out                <= rd_reg_cmd_out;   
43
    arg_out                <= rd_reg_arg_out;
44
  end if;   
45
end process;

: Edited by Moderator
von Julian M. (Company: Relevant Technologies Ltd) (geoffreym)


Rate this post
useful
not useful
Many thanks, I work alone, and still make some godawful blunders, having 
been doing this for about two years. Great fun, and a big paradigm shift 
from software, a background many will no doubt spot, due to my 
parentheses around conditions in if- statements.

von Julian M. (Company: Relevant Technologies Ltd) (geoffreym)


Rate this post
useful
not useful
The clocked processes are using these resources, and of the usual sort. 
They are all state machines, which have an idle state in which they do 
nothing at all. So this is combinatorial logic in support of them. They 
are assumed to execute exclusively, and, as soon as they enter a state 
other than "???_IDLE" the bit is set.

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.