| Line | |
|---|
| 1 | module 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 | |
|---|
| 8 | input clk; |
|---|
| 9 | output read_req, write_req, data; // output: requests to cache |
|---|
| 10 | output [`address_size:0] address; // output: request to cache |
|---|
| 11 | input acknowledge; // input: answer from cache |
|---|
| 12 | input [`address_size:0] any_address; |
|---|
| 13 | input any_value; |
|---|
| 14 | input inst; |
|---|
| 15 | |
|---|
| 16 | wire read_req, write_req, data; |
|---|
| 17 | wire [`address_size:0] address; |
|---|
| 18 | Instruction_type wire inst; |
|---|
| 19 | Processor_state reg proc_state; |
|---|
| 20 | // local data of the processor |
|---|
| 21 | |
|---|
| 22 | initial begin |
|---|
| 23 | proc_state = IDLE; |
|---|
| 24 | end |
|---|
| 25 | |
|---|
| 26 | assign read_req = ((proc_state==IDLE)?((inst==READ_WORD)?1:0):((proc_state == READING)?1:0)); |
|---|
| 27 | assign write_req = ((proc_state==IDLE)?((inst==WRITE_WORD)?1:0):((proc_state == WRITING)?1:0)); |
|---|
| 28 | assign data = any_value; |
|---|
| 29 | assign address = any_address; |
|---|
| 30 | |
|---|
| 31 | always @(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; |
|---|
| 71 | end // end of always statement describing processor automaton |
|---|
| 72 | endmodule |
|---|
| 73 | |
|---|
| 74 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.