From a1690862f7e2cec3395729596bc642df7d87c43f Mon Sep 17 00:00:00 2001 From: Till Harbaum Date: Sat, 8 Sep 2018 21:54:23 +0200 Subject: [PATCH] Added ypbpr support to atari st core --- cores/mist/mist.qws | Bin 790 -> 0 bytes cores/mist/mist_top.v | 5 ++-- cores/mist/rgb2ypbpr.sv | 55 ++++++++++++++++++++++++++++++++++++++++ cores/mist/user_io.v | 8 +++--- cores/mist/video.v | 32 ++++++++++++++++++----- 5 files changed, 89 insertions(+), 11 deletions(-) delete mode 100644 cores/mist/mist.qws create mode 100644 cores/mist/rgb2ypbpr.sv diff --git a/cores/mist/mist.qws b/cores/mist/mist.qws deleted file mode 100644 index f05f7ae2066fe3dffcef87edb4c8eeae097b58e1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 790 zcmchVO-sW-5Qg6*9(wfT$%6-xBDATZRc|8bsVDI&60?adHKxS+0U~<#uX*w6e^Ki* zOQcXl(1R1^V`tyld3QFuO?}Ct&Xwp=W1Z+mr78_sjmV|S00n5SSbg>iGBLjvRV0-_6>}^oN6J~uc6rwBY!8K=& zOWI?mW4=-std8&{FJ!Z>45|rYzLt3%P?~XBgQOaM2lCV?XzGv`I^+HR(8&%qUG}6# zKU4MWW~eSunCaH{-iPqO-?B1tv$u*!S$>sql)!8p#qT?|gV&d5e~|U?5 235) ? 8'd235 : y_8[15:8]; +wire [7:0] pb_i = (pb_8[17:8] < 16) ? 8'd16 : (pb_8[17:8] > 240) ? 8'd240 : pb_8[15:8]; +wire [7:0] pr_i = (pr_8[17:8] < 16) ? 8'd16 : (pr_8[17:8] > 240) ? 8'd240 : pr_8[15:8]; + +assign pr = yuv_full[pr_i - 8'd16]; +assign y = yuv_full[y_i - 8'd16]; +assign pb = yuv_full[pb_i - 8'd16]; + +endmodule diff --git a/cores/mist/user_io.v b/cores/mist/user_io.v index d175acf..829df9b 100644 --- a/cores/mist/user_io.v +++ b/cores/mist/user_io.v @@ -59,7 +59,8 @@ module user_io( // on-board buttons and dip switches output [1:0] BUTTONS, output [1:0] SWITCHES, - output scandoubler_disable + output scandoubler_disable, + output ypbpr ); // filter spi clock. the 8 bit gate delay is ~2.5ns in total @@ -70,7 +71,7 @@ reg [3:0] byte_cnt; reg [6:0] sbuf; reg [7:0] cmd; reg [3:0] bit_cnt; // 0..15 -reg [4:0] but_sw; +reg [5:0] but_sw; // counter runs 0..7,8..15,8..15,8..15 wire [2:0] tx_bit = ~(bit_cnt[2:0]); @@ -78,6 +79,7 @@ wire [2:0] tx_bit = ~(bit_cnt[2:0]); assign BUTTONS = but_sw[1:0]; assign SWITCHES = but_sw[3:2]; assign scandoubler_disable = but_sw[4]; +assign ypbpr = but_sw[5]; // prepent "a5" to status to make sure io controller can detect that a core // doesn't support the command @@ -204,7 +206,7 @@ always@(negedge spi_sck) begin eth_mac_begin <= 1'b0; if(cmd == 1) - but_sw <= { sbuf[3:0], SPI_MOSI }; + but_sw <= { sbuf[4:0], SPI_MOSI }; // send ikbd byte to acia if(cmd == 2) begin diff --git a/cores/mist/video.v b/cores/mist/video.v index 993a23c..25f4b11 100644 --- a/cores/mist/video.v +++ b/cores/mist/video.v @@ -59,7 +59,8 @@ module video ( // system config input viking_enable, // enable viking video card input viking_himem, // let viking use memory from $e80000 - input scandoubler_disable, // don't use scandoubler in 15khz modes + input scandoubler_disable, // don't use scandoubler in 15khz modes + input ypbpr, // output ypbpr instead of rgb input pal56, // use VGA compatible 56hz for PAL input [1:0] scanlines, // scanlines (00-none 01-25% 10-50% 11-100%) input [15:0] adjust, // hor/ver video adjust @@ -75,13 +76,15 @@ module video ( assign vaddr = viking_enable?viking_vaddr:shifter_vaddr; assign read = viking_enable?viking_read:shifter_read; +wire ypbpr_cs = ~(shifter_sd_adjusted_hs ^ shifter_sd_adjusted_vs); + // if we use 15khz signals without scan doubler then we need // to create a composite sync on hsync wire enable_csync = sd_15khz_detected && scandoubler_disable; // wire csync = shifter_hs == shifter_vs; wire csync = shifter_sd_adjusted_hs == shifter_sd_adjusted_vs; -assign hs = enable_csync?csync:stvid_hs; -assign vs = enable_csync?1'b1:stvid_vs; +assign hs = enable_csync?csync:ypbpr?ypbpr_cs:stvid_hs; +assign vs = (enable_csync || ypbpr)?1'b1:stvid_vs; // ------------------------- OSD --------------------------- @@ -92,7 +95,24 @@ always @(posedge clk_128) wire osd_clk = viking_enable?clk_128:clk_32; +wire [5:0] y, pb, pr; +rgb2ypbpr rgb2ypbpr ( + .red ( osd_r ), + .green ( osd_g ), + .blue ( osd_b ), + + .y ( y ), + .pb ( pb ), + .pr ( pr ) +); + +// demultiplex between ypbpr and rgb signals +assign video_r = ypbpr?pr:osd_r; +assign video_g = ypbpr? y:osd_g; +assign video_b = ypbpr?pb:osd_b; + // include OSD overlay +wire [5:0] osd_r, osd_g, osd_b; osd osd ( .clk ( osd_clk ), @@ -110,9 +130,9 @@ osd osd ( .b_in ( ovl_b ), // receive signal with OSD overlayed - .r_out ( video_r ), - .g_out ( video_g ), - .b_out ( video_b ) + .r_out ( osd_r ), + .g_out ( osd_g ), + .b_out ( osd_b ) ); // include debug overlay