Files
Basys3Terminal/rtl/fifo.v
T
barantandClaude Opus 5.5 6e54d75c56 VT220 emulation with ANSI colour, underline and smooth scrolling
- Terminal engine rewritten for VT220: scroll regions, IL/DL/ICH/DCH/ECH,
  SU/SD, origin mode, insert mode, tab stops, DEC special graphics with
  G0/G1 and SO/SI, DECSC/DECRC, DECSTR, RIS, DECALN, DECLL LEDs
- Replies to DA, secondary DA, DSR and CPR over the UART
- 16-colour SGR (256-colour and RGB approximated), bold, underline,
  blink, reverse and conceal; cells are now 18 bits
- Smooth scrolling (SW8 or DECSCLM): the region slides per frame and
  rows are moved during vertical blanking; XON/XOFF holds the host back
- Keyboard: DECCKM, keypad application mode, F5-F12, VT220 Home/End,
  Alt as ESC prefix
- basys3 terminfo entry (vt220 + 16 colours, 30 lines)
- Flash script reboots the FPGA from flash after programming
- Testbench covers replies, modes, attributes, editing and smooth scroll

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 11:18:36 -08:00

39 lines
944 B
Verilog

`timescale 1ns / 1ps
// Small synchronous first-word-fall-through FIFO (dout is valid while !empty).
module fifo #(
parameter W = 8,
parameter A = 4 // depth = 2**A
) (
input clk,
input rst,
input [W-1:0] din,
input wr,
input rd,
output [W-1:0] dout,
output empty,
output full,
output [A:0] count
);
reg [W-1:0] mem [0:(1<<A)-1];
reg [A:0] wp, rp;
assign empty = wp == rp;
assign full = wp[A] != rp[A] && wp[A-1:0] == rp[A-1:0];
assign dout = mem[rp[A-1:0]];
assign count = wp - rp;
always @(posedge clk)
if (wr && !full) mem[wp[A-1:0]] <= din;
always @(posedge clk) begin
if (rst) begin
wp <= 0;
rp <= 0;
end else begin
if (wr && !full) wp <= wp + 1'b1;
if (rd && !empty) rp <= rp + 1'b1;
end
end
endmodule