Merge pull request #14 from JimmyStones/main

Update sys
This commit is contained in:
Jim Gregory
2025-01-05 18:37:52 +00:00
committed by GitHub
8 changed files with 56 additions and 22 deletions

View File

@@ -57,6 +57,7 @@ module emu
input [11:0] HDMI_WIDTH,
input [11:0] HDMI_HEIGHT,
output HDMI_FREEZE,
output HDMI_BLACKOUT,
`ifdef MISTER_FB
// Use framebuffer in DDRAM
@@ -187,6 +188,7 @@ assign VGA_F1 = 0;
assign VGA_SCALER = 0;
assign VGA_DISABLE = 0;
assign HDMI_FREEZE = 0;
assign HDMI_BLACKOUT = 0;
assign AUDIO_S = 1;
assign AUDIO_MIX = 0;

Binary file not shown.

View File

@@ -222,6 +222,7 @@ ENTITY ascal IS
vmax : IN natural RANGE 0 TO 4095; -- 0 <= vmin < vmax < vdisp
vrr : IN std_logic := '0';
vrrmax : IN natural RANGE 0 TO 4095 := 0;
swblack : IN std_logic := '0'; -- will output 3 black frame on every resolution switch
-- Scaler format. 00=16bpp 565, 01=24bpp 10=32bpp
format : IN unsigned(1 DOWNTO 0) :="01";
@@ -510,6 +511,7 @@ ARCHITECTURE rtl OF ascal IS
SIGNAL o_divrun : std_logic;
SIGNAL o_hacpt,o_vacpt : unsigned(11 DOWNTO 0);
SIGNAL o_vacptl : unsigned(1 DOWNTO 0);
signal o_newres : integer range 0 to 3;
-----------------------------------------------------------------------------
FUNCTION shift_ishift(shift : unsigned(0 TO 119);
@@ -1890,6 +1892,14 @@ BEGIN
o_ivsize<=i_vrsize; -- <ASYNC>
o_hdown<=i_hdown; -- <ASYNC>
o_vdown<=i_vdown; -- <ASYNC>
IF (o_newres > 0) then
o_newres <= o_newres- 1;
END IF;
END IF;
IF (swblack = '1' and o_fb_ena = '0' and (o_ihsize /= i_hrsize or o_ivsize /= i_vrsize)) then
o_newres <= 3;
END IF;
-- Simultaneous change of input and output framebuffers
@@ -2219,6 +2229,9 @@ BEGIN
hpix_v:=(r=>o_fb_pal_dr(23 DOWNTO 16),g=>o_fb_pal_dr(15 DOWNTO 8),
b=>o_fb_pal_dr(7 DOWNTO 0));
END IF;
IF (o_newres > 0) then
hpix_v := (others => (others => '0'));
END IF;
o_hpix0<=hpix_v;
o_hpix1<=o_hpix0;
o_hpix2<=o_hpix1;

View File

@@ -27,7 +27,7 @@
// VDNUM 1..10
// BLKSZ 0..7: 0 = 128, 1 = 256, 2 = 512(default), .. 7 = 16384
//
module hps_io #(parameter CONF_STR, CONF_STR_BRAM=1, PS2DIV=0, WIDE=0, VDNUM=1, BLKSZ=2, PS2WE=0)
module hps_io #(parameter CONF_STR, CONF_STR_BRAM=0, PS2DIV=0, WIDE=0, VDNUM=1, BLKSZ=2, PS2WE=0, STRLEN=$size(CONF_STR)>>3)
(
input clk_sys,
inout [48:0] HPS_BUS,
@@ -39,7 +39,7 @@ module hps_io #(parameter CONF_STR, CONF_STR_BRAM=1, PS2DIV=0, WIDE=0, VDNUM=1,
output reg [31:0] joystick_3,
output reg [31:0] joystick_4,
output reg [31:0] joystick_5,
// analog -127..+127, Y: [15:8], X: [7:0]
output reg [15:0] joystick_l_analog_0,
output reg [15:0] joystick_l_analog_1,
@@ -232,7 +232,6 @@ video_calc video_calc
/////////////////////////////////////////////////////////
localparam STRLEN = $size(CONF_STR)>>3;
localparam MAX_W = $clog2((64 > (STRLEN+2)) ? 64 : (STRLEN+2))-1;
wire [7:0] conf_byte;
@@ -281,7 +280,7 @@ always@(posedge clk_sys) begin : uio_block
stflg <= stflg + 1'd1;
status_req <= status_in;
end
old_upload_req <= ioctl_upload_req;
if(~old_upload_req & ioctl_upload_req) upload_req <= 1;
@@ -523,7 +522,7 @@ always@(posedge clk_sys) begin : uio_block
//menu mask
'h2E: if(byte_cnt == 1) io_dout <= status_menumask;
//sdram size set
'h31: if(byte_cnt == 1) sdram_sz <= io_din;
@@ -630,7 +629,7 @@ always@(posedge clk_sys) begin : fio_block
reg has_cmd;
reg [26:0] addr;
reg wr;
ioctl_rd <= 0;
ioctl_wr <= wr;
wr <= 0;
@@ -663,7 +662,7 @@ always@(posedge clk_sys) begin : fio_block
FIO_FILE_TX:
begin
cnt <= cnt + 1'd1;
case(cnt)
case(cnt)
0: if(io_din[7:0] == 8'hAA) begin
ioctl_addr <= 0;
ioctl_upload <= 1;
@@ -1032,8 +1031,15 @@ module confstr_rom #(parameter CONF_STR, STRLEN)
output reg [7:0] conf_byte
);
wire [7:0] rom[STRLEN];
initial for(int i = 0; i < STRLEN; i++) rom[i] = CONF_STR[((STRLEN-i)*8)-1 -:8];
reg [7:0] rom[STRLEN];
initial begin
if( CONF_STR=="" )
$readmemh("cfgstr.hex",rom);
else
for(int i = 0; i < STRLEN; i++) rom[i] = CONF_STR[((STRLEN-i)*8)-1 -:8];
end
always @ (posedge clk_sys) conf_byte <= rom[conf_addr];
endmodule

View File

@@ -75,7 +75,7 @@ always @(posedge CLK) begin
END <= 0;
rd <= READ;
len <= I2C_WLEN;
if(READ) SD <= {2'b10, I2C_ADDR, 1'b1, 1'b1, 8'b11111111, 1'b0, 3'b011, 9'b111111111};
if(READ) SD <= {2'b10, I2C_ADDR, 1'b1, 1'b1, 8'b11111111, 1'b1, 3'b011, 9'b111111111};
else SD <= {2'b10, I2C_ADDR, 1'b0, 1'b1, I2C_WDATA1, 1'b1, I2C_WDATA2, 4'b1011};
SD_COUNTER <= 0;
end else begin

View File

@@ -58,10 +58,10 @@ localparam DW = WIDE ? 15 : 7;
localparam SZ = OCTAL ? 8 : 1;
localparam SW = SZ-1;
wire [7:0] DATA_TOKEN_CMD25 = 8'hfc;
wire [7:0] STOP_TRAN = 8'hfd;
wire [7:0] DATA_TOKEN = 8'hfe;
wire [7:0] WRITE_DATA_RESPONSE = 8'h05;
localparam DATA_TOKEN_CMD25 = 8'hfc;
localparam STOP_TRAN = 8'hfd;
localparam DATA_TOKEN = 8'hfe;
localparam WRITE_DATA_RESPONSE = 8'he5;
// number of bytes to wait after a command before sending the reply
localparam NCR = 5+3; // 5 bytes are required (command length)

View File

@@ -128,12 +128,13 @@ module sys_top
wire SD_CS, SD_CLK, SD_MOSI, SD_MISO, SD_CD;
`ifndef MISTER_DUAL_SDRAM
assign SD_CD = mcp_en ? mcp_sdcd : SDCD_SPDIF;
wire sd_cd = SDCD_SPDIF & ~SW[2]; // SW[2]=ON workaround for faulty boards without SD card detect pin.
assign SD_CD = mcp_en ? mcp_sdcd : sd_cd;
assign SD_MISO = SD_CD | (mcp_en ? SD_SPI_MISO : (VGA_EN | SDIO_DAT[0]));
assign SD_SPI_CS = mcp_en ? (mcp_sdcd ? 1'bZ : SD_CS) : (sog & ~cs1 & ~VGA_EN) ? 1'b1 : 1'bZ;
assign SD_SPI_CLK = (~mcp_en | mcp_sdcd) ? 1'bZ : SD_CLK;
assign SD_SPI_MOSI = (~mcp_en | mcp_sdcd) ? 1'bZ : SD_MOSI;
assign {SDIO_CLK,SDIO_CMD,SDIO_DAT} = av_dis ? 6'bZZZZZZ : (mcp_en | (SDCD_SPDIF & ~SW[2])) ? {vga_g,vga_r,vga_b} : {SD_CLK,SD_MOSI,SD_CS,3'bZZZ};
assign {SDIO_CLK,SDIO_CMD,SDIO_DAT} = av_dis ? 6'bZZZZZZ : (mcp_en | sd_cd) ? {vga_g,vga_r,vga_b} : {SD_CLK,SD_MOSI,SD_CS,3'bZZZ};
`else
assign SD_CD = mcp_sdcd;
assign SD_MISO = mcp_sdcd | SD_SPI_MISO;
@@ -183,10 +184,10 @@ wire io_dig = mcp_en ? mcp_mode : SW[3];
assign LED_USER = VGA_TX_CLK;
wire BTN_DIS = VGA_EN;
`else
wire BTN_RESET = SDRAM2_DQ[9];
wire BTN_OSD = SDRAM2_DQ[13];
wire BTN_USER = SDRAM2_DQ[11];
wire BTN_DIS = SDRAM2_DQ[15];
wire BTN_RESET = 1'b1;
wire BTN_OSD = 1'b1;
wire BTN_USER = 1'b1;
wire BTN_DIS = 1'b1;
`endif
reg BTN_EN = 0;
@@ -331,6 +332,7 @@ reg [11:0] vs_line = 0;
reg scaler_out = 0;
reg vrr_mode = 0;
wire hdmi_blackout;
reg [31:0] aflt_rate = 7056000;
reg [39:0] acx = 4258969;
@@ -752,6 +754,7 @@ wire freeze;
.vmax (vmax),
.vrr (vrr_mode),
.vrrmax (HEIGHT + VBP + VS[11:0] + 12'd1),
.swblack (hdmi_blackout),
.mode ({~lowlat,LFB_EN ? LFB_FLT : |scaler_flt,2'b00}),
.poly_clk (clk_sys),
@@ -1734,6 +1737,7 @@ emu emu
.HDMI_WIDTH(direct_video ? 12'd0 : hdmi_width),
.HDMI_HEIGHT(direct_video ? 12'd0 : hdmi_height),
.HDMI_FREEZE(freeze),
.HDMI_BLACKOUT(hdmi_blackout),
.CLK_VIDEO(clk_vid),
.CE_PIXEL(ce_pix),

View File

@@ -26,6 +26,10 @@ module video_cleaner
//optional de
input DE_in,
//optional interlace support
input interlace,
input f1,
// video output signals
output reg [7:0] VGA_R,
output reg [7:0] VGA_G,
@@ -56,14 +60,19 @@ always @(posedge clk_vid) begin
HBlank_out <= hbl;
VGA_HS <= hs;
if(~VGA_HS & hs) VGA_VS <= vs;
VGA_R <= R;
VGA_G <= G;
VGA_B <= B;
DE_out <= DE_in;
if(HBlank_out & ~hbl) VBlank_out <= vbl;
if (interlace & f1) begin
VGA_VS <= vs;
VBlank_out <= vbl;
end else begin
if(~VGA_HS & hs) VGA_VS <= vs;
if(HBlank_out & ~hbl) VBlank_out <= vbl;
end
end
end