source: vis_dev/vis-2.1/examples/coherence/processor.v @ 14

Last change on this file since 14 was 11, checked in by cecile, 13 years ago

Add vis

File size: 1.8 KB
Line 
1module PROC (
2  clk,
3  read_req, write_req, data, address,      // output: requests to cache
4  acknowledge,                             // input: answer from cache
5  any_address, any_value, inst      // input: for non determinism
6  );
7
8input clk;
9output read_req, write_req, data;          // output: requests to cache
10output [`address_size:0] address;          // output: request to cache
11input acknowledge;                         // input: answer from cache
12input [`address_size:0] any_address; 
13input any_value;
14input inst;
15
16wire read_req, write_req, data;
17wire [`address_size:0] address; 
18Instruction_type wire inst;
19Processor_state reg proc_state;
20      // local data of the processor
21
22initial begin
23  proc_state = IDLE;
24end
25
26assign read_req = ((proc_state==IDLE)?((inst==READ_WORD)?1:0):((proc_state == READING)?1:0));
27assign write_req = ((proc_state==IDLE)?((inst==WRITE_WORD)?1:0):((proc_state == WRITING)?1:0));
28assign data = any_value;
29assign address = any_address;
30
31always @(posedge clk) begin
32   case ( proc_state )
33
34      IDLE : 
35        begin
36         case (inst)
37
38            COMPUTE: begin
39               proc_state = IDLE;
40            end
41
42            READ_WORD: begin
43               proc_state = READING;
44            end
45
46            WRITE_WORD: begin
47               proc_state = WRITING;
48            end
49
50         default: begin
51               proc_state = IDLE;
52            end
53         
54         endcase;
55        end
56      READING : 
57         if (acknowledge)       // data arrived from cache
58         begin
59               proc_state = IDLE;
60         end
61
62
63      WRITING : 
64         if (acknowledge)       // data arrived from cache
65         begin
66               proc_state = IDLE;
67         end
68
69
70   endcase;
71end // end of always statement describing processor automaton
72endmodule
73
74
Note: See TracBrowser for help on using the repository browser.