티스토리 뷰
728x90
반응형
// Code your design here
module wb_block(
// between controller
input wb_start,
output reg wb_done,
// between directory
input [31:0] wb_address,
input [(32*8)-1:0] wb_cache_line,
// between sram
output reg req_valid,
output reg [31:0] req_data,
output reg req_wren,
output reg [31:0] req_address,
input req_ready,
input clk,
input rstn
);
// state
localparam IDLE = 1'b0;
localparam EXEC = 1'b1;
// reg
reg current_state, next_state;
reg [3:0] captured_cnt;
// wire
wire [3:0] cnt;
// pulse_counter
pulse_counter u1(.source(current_state), .cnt(cnt), .clk(clk), .rstn(rstn));
// FF for state
always @(posedge clk or negedge rstn) begin
if (!rstn) begin
current_state <= 0;
end
else begin
current_state <= next_state;
end
end
// ff for captured_cnt
always @(posedge clk or negedge rstn) begin
if (!rstn) begin
captured_cnt <= 0;
end
else begin
if (current_state == IDLE) begin
captured_cnt <= cnt;
end
else begin
captured_cnt <= captured_cnt;
end
end
end
// next_state
always @(*) begin
case (current_state)
IDLE : begin
if (wb_start == 1 && cnt < 8) begin
next_state = EXEC;
end
else begin
next_state = IDLE;
end
end
EXEC : begin
if (req_ready == 0) begin
next_state = EXEC;
end
else begin
next_state = IDLE;
end
end
endcase
end
// output
always @(*) begin
case (current_state)
IDLE : begin
req_valid = 0;
end
EXEC : begin
req_valid = 1;
req_address = wb_address + captured_cnt * 4;
req_data = wb_cache_line[captured_cnt*32 +: 32];
req_wren = 1;
end
endcase
end
// done
always @(*) begin
if(wb_start == 1 && cnt >= 8) begin
wb_done = 1;
end
else begin
wb_done = 0;
end
end
endmodule
728x90
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 너비우선탐색
- C언어
- BOJ
- 재귀함수
- gem5
- 완전탐색
- 스택
- 건이의 특제 떡국 끓이기
- 정렬
- 큐
- 백준
- 구조체
- 영어 어휘
- 영화
- 백트래킹
- recursive
- Verilog
- 베릴로그
- backtracking
- Push
- 이진탐색
- 메이플스토리
- 이분법
- BFS
- 구현
- Git
- 취미
- C++
- 애니메이션
- 알고리즘
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
글 보관함
반응형
250x250