Advertisement
aidanozohor1810

Untitled

Dec 6th, 2023
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. `define reset                   'h00            // reset state
  2. `define fetch                   'h10            // load instruction to instruction register
  3.  
  4. reg [state_width-1 : 0] state = `reset, state_next;
  5.  
  6. // FSM - sequential part
  7. always @(posedge clk) begin
  8.     state <= `reset;
  9.  
  10.     if(!rst)
  11.         state <= state_next;
  12. end
  13.  
  14.     case(state)
  15.         `reset: begin
  16.             state_next = `fetch;
  17.         end
  18.  
  19.         `fetch: begin
  20.             cp_oe = 1;
  21.             am_we = 1;
  22.  
  23.             state_next = `fetch + 1;
  24.         end
  25.  
  26.         `fetch + 'd1: begin
  27.             am_oe = 1;
  28.  
  29.             state_next = `fetch + 2;
  30.         end
  31.  
  32.         `fetch + 'd2: begin
  33.             ram_oe = 1;
  34.             ri_we = 1;
  35.  
  36.             state_next = `reset;
  37.         end
  38.  
  39.         default: ;
  40.     endcase
  41. end
  42.  
  43. assign disp_state = state;
  44.  
  45. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement