generated from saji/ecp5-template
wip: bitslicer
This commit is contained in:
parent
31d612a2e8
commit
bd2fa51f2d
57
verilog/bitslicer.sv
Normal file
57
verilog/bitslicer.sv
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
module bitslicer (
|
||||||
|
input clk,
|
||||||
|
input [23:0] rgb[2],
|
||||||
|
input [7:0] pixnum, // x-value of the pixels we are being fed.
|
||||||
|
input start_write,
|
||||||
|
output reg [5:0] bitplane_data,
|
||||||
|
output [10:0] bitplane_addr,
|
||||||
|
output reg bitplane_wren,
|
||||||
|
output reg done
|
||||||
|
);
|
||||||
|
|
||||||
|
reg [3:0] bitplane_bit = 0;
|
||||||
|
assign bitplane_addr = (pixnum << 3) + bitplane_bit;
|
||||||
|
|
||||||
|
reg [3:0] state = StateInit;
|
||||||
|
localparam integer StateInit = 0;
|
||||||
|
localparam integer StateWriteout = 1;
|
||||||
|
localparam integer StateDone = 2;
|
||||||
|
|
||||||
|
|
||||||
|
always @(posedge clk) begin
|
||||||
|
case (state)
|
||||||
|
StateInit: begin
|
||||||
|
bitplane_bit <= 0;
|
||||||
|
done <= 0;
|
||||||
|
bitplane_wren <= 0;
|
||||||
|
if (start_write) begin
|
||||||
|
state <= StateWriteout;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
StateWriteout: begin
|
||||||
|
bitplane_data <= {
|
||||||
|
rgb[1][bitplane_bit],
|
||||||
|
rgb[1][bitplane_bit+8],
|
||||||
|
rgb[1][bitplane_bit+16],
|
||||||
|
rgb[0][bitplane_bit],
|
||||||
|
rgb[0][bitplane_bit+8],
|
||||||
|
rgb[0][bitplane_bit+16]
|
||||||
|
};
|
||||||
|
bitplane_wren <= 1;
|
||||||
|
bitplane_bit <= bitplane_bit + 1;
|
||||||
|
|
||||||
|
if (bitplane_bit == 7) begin
|
||||||
|
state <= StateDone;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
StateDone: begin
|
||||||
|
bitplane_wren <= 0;
|
||||||
|
done <= 1; // strobe
|
||||||
|
state <= StateInit;
|
||||||
|
end
|
||||||
|
default: begin
|
||||||
|
state <= StateInit;
|
||||||
|
end
|
||||||
|
endcase
|
||||||
|
end
|
||||||
|
endmodule
|
0
verilog/tb/bitslicer_tb.sv
Normal file
0
verilog/tb/bitslicer_tb.sv
Normal file
Loading…
Reference in a new issue