OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [boards/] [actel/] [ordb1a3pe1500/] [rtl/] [verilog/] [versatile_mem_ctrl/] [rtl/] [verilog/] [fsm_wb.v] - Blame information for rev 724

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 408 julius
module fsm_wb (
2
               stall_i, stall_o,
3
               we_i, cti_i, bte_i, stb_i, cyc_i, ack_o,
4
               egress_fifo_we, egress_fifo_full,
5
               ingress_fifo_re, ingress_fifo_empty,
6
               state_idle,
7
               sdram_burst_reading,
8
               debug_state,
9
               wb_clk, wb_rst
10
               );
11
 
12
   input stall_i;
13
   output stall_o;
14
 
15
   input [2:0] cti_i;
16
   input [1:0] bte_i;
17
   input       we_i, stb_i, cyc_i;
18
   output      ack_o;
19
   output      egress_fifo_we, ingress_fifo_re;
20
   input       egress_fifo_full, ingress_fifo_empty;
21
   input       sdram_burst_reading;
22
   output      state_idle;
23
   input       wb_clk, wb_rst;
24
   output [1:0] debug_state;
25
 
26
 
27
 
28
   reg         ingress_fifo_read_reg;
29
 
30
   // bte
31
   parameter linear       = 2'b00;
32
   parameter wrap4        = 2'b01;
33
   parameter wrap8        = 2'b10;
34
   parameter wrap16       = 2'b11;
35
   // cti
36
   parameter classic      = 3'b000;
37
   parameter endofburst   = 3'b111;
38
 
39
   parameter idle = 2'b00;
40
   parameter rd   = 2'b01;
41
   parameter wr   = 2'b10;
42
   parameter fe   = 2'b11;
43
   reg [1:0]   state;
44
 
45
   assign debug_state = state;
46
 
47
 
48
   reg         sdram_burst_reading_1, sdram_burst_reading_2;
49
   wire        sdram_burst_reading_wb_clk;
50
 
51
 
52
   always @ (posedge wb_clk or posedge wb_rst)
53
     if (wb_rst)
54
       state <= idle;
55
     else
56
       case (state)
57
         idle:
58
           if (we_i & stb_i & cyc_i & !egress_fifo_full & !stall_i)
59
             state <= wr;
60
           else if (!we_i & stb_i & cyc_i & !egress_fifo_full & !stall_i)
61
             state <= rd;
62
         wr:
63
           if ((cti_i==classic | cti_i==endofburst | bte_i==linear) &
64
               stb_i & cyc_i & !egress_fifo_full & !stall_i)
65
             state <= idle;
66
         rd:
67
           if ((cti_i==classic | cti_i==endofburst | bte_i==linear) &
68
               stb_i & cyc_i & ack_o)
69
             state <= fe;
70
         fe:
71
           if (ingress_fifo_empty & !sdram_burst_reading_wb_clk)
72
             state <= idle;
73
         default: ;
74
       endcase
75
 
76
   assign state_idle = (state==idle);
77
 
78
   assign stall_o = (stall_i) ? 1'b1 :
79
                    (state==idle & stb_i & cyc_i & !egress_fifo_full) ? 1'b1 :
80
                    (state==wr   & stb_i & cyc_i & !egress_fifo_full) ? 1'b1 :
81
                    (state==rd   & stb_i & cyc_i & !ingress_fifo_empty) ? 1'b1 :
82
                    (state==fe   & !ingress_fifo_empty) ? 1'b1 :
83
                    1'b0;
84
 
85
   assign egress_fifo_we = (state==idle & stb_i & cyc_i & !egress_fifo_full & !stall_i) ? 1'b1 :
86
                           (state==wr   & stb_i & cyc_i & !egress_fifo_full & !stall_i) ? 1'b1 :
87
                           1'b0;
88
 
89
   assign ingress_fifo_re = (state==rd & stb_i & cyc_i & !ingress_fifo_empty & !stall_i) ? 1'b1 :
90
                            (state==fe & !ingress_fifo_empty & !stall_i) ? 1'b1:
91
                            1'b0;
92
 
93
   always @ (posedge wb_clk or posedge wb_rst)
94
     if (wb_rst)
95
       ingress_fifo_read_reg <= 1'b0;
96
     else
97
       ingress_fifo_read_reg <= ingress_fifo_re;
98
 
99
   /*assign ack_o = (ingress_fifo_read_reg & stb_i) ? 1'b1 :
100
                  (state==fe) ? 1'b0 :
101
                  (state==wr & stb_i & cyc_i & !egress_fifo_full & !stall_i) ? 1'b1 :
102
                  1'b0;*/
103
 
104
   assign ack_o = !(state==fe) & ((ingress_fifo_read_reg & stb_i) | (state==wr & stb_i & cyc_i & !egress_fifo_full & !stall_i));
105
 
106
 
107
   // Sample the SDRAM burst reading signal in WB domain
108
   always @(posedge wb_clk)
109
     sdram_burst_reading_1 <= sdram_burst_reading;
110
 
111
   always @(posedge wb_clk)
112
     sdram_burst_reading_2 <= sdram_burst_reading_1;
113
 
114
   assign sdram_burst_reading_wb_clk = sdram_burst_reading_2;
115
 
116
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.