From 73b0e7ea6bf3b731a6300d7bd0df4183f3471376 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Sat, 12 Nov 2016 11:05:07 -0800 Subject: Avoid latch in video_width; allow flipping sw9 at runtime Avoid latching video_width. Also track sw[9] and allow it to set the video_width at runtime by flipping the switch (it may or may not change the width based on previous state.) Signed-off-by: H. Peter Anvin --- abc80.v | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/abc80.v b/abc80.v index d79c66d..b730a63 100644 --- a/abc80.v +++ b/abc80.v @@ -1080,16 +1080,25 @@ module abc80 ( .strobe ( key1_strobe ) ); + reg video_width_sw_q; + always @(negedge rst_n or posedge cpu_clk) begin if ( ~rst_n ) - video_width <= ~sw[9]; // Set SW9 to go to 40 column after reset + begin + video_width <= 1'b0; + video_width_sw_q <= 1'b0; + end else begin + video_width_sw_q <= ~sw[9]; + if ( ~abc_in_n[3] ) video_width <= 1'b0; else if ( ~abc_in_n[4] ) video_width <= 1'b1; + else if ( ~sw[9] ^ video_width_sw_q ) + video_width <= ~sw[9]; else if ( key1_strobe & key1_debounced ) video_width <= ~video_width; end @@ -1196,7 +1205,7 @@ module abc80 ( wire intio_sel; // Selected for access via I/O ports reg [7:0] intio_do; // Data out from MMU I/O ports reg intio_sel_q; - reg abc_out_7_q; + reg abc_out_7_q; reg turbo_set; reg nmi_dis; -- cgit v1.2.3