diff --git a/Ampelansteuerung/LED_control.sv b/Ampelansteuerung/LED_control.sv index 4fc7b0a..f4bc431 100644 --- a/Ampelansteuerung/LED_control.sv +++ b/Ampelansteuerung/LED_control.sv @@ -64,13 +64,13 @@ module LED_control1 ( // inputs - input wire clk12M, // 12M clock - input wire rst, //Asynchronous reset + input wire clk12M, // 12M clock + input wire rst, // Asynchronous reset input wire [1:0] color_sel, // for selecting color using switches - input wire RGB_Blink_En, //Enabling Blink + input wire rw, // read or write select switch //outputs - output reg red_pwm, // Red - output reg blu_pwm, // Blue + output reg red_pwm, // Red + output reg blu_pwm, // Blue output reg grn_pwm // Green ); @@ -160,16 +160,16 @@ always @ (posedge clk24M or posedge rst) Brightness_s <= 4'b0111; BreatheRamp_s <= 4'b0000; BlinkRate_s <= 4'b0101; - end else if(!RGB_Blink_En) begin - RGB_color_s <= RGB_color ; - Brightness_s <= Brightness ; - BreatheRamp_s <= 4'b0000 ; - BlinkRate_s <= 4'b0000 ; + //end else if(!RGB_Blink_En) begin //TODO ReadWrite Difference + //RGB_color_s <= RGB_color ; + //Brightness_s <= Brightness ; + //BreatheRamp_s <= 4'b0000 ; + //BlinkRate_s <= 4'b0000 ; end else begin RGB_color_s <= RGB_color ; Brightness_s <= Brightness ; - BreatheRamp_s <= BreatheRamp ; - BlinkRate_s <= BlinkRate ; + BreatheRamp_s <= 4'b0000 ; + BlinkRate_s <= 4'b0000 ; end diff --git a/Ampelansteuerung/rgb_led_top.sv b/Ampelansteuerung/rgb_led_top.sv deleted file mode 100644 index 1501b14..0000000 --- a/Ampelansteuerung/rgb_led_top.sv +++ /dev/null @@ -1,70 +0,0 @@ -module led_top ( -input wire clk12M, -input wire rst, -input wire [1:0] color_sel, -input wire RGB_Blink_En, -output reg REDn, -output reg BLUn, -output reg GRNn, -output reg RED, -output reg BLU, -output reg GRN -); - -wire red_pwm; -wire grn_pwm; -wire blu_pwm; - -//parameter on_hi = 2'b10; -//parameter on_lo = 2'b01; -//parameter off = 2'b00; -//parameter LED_OFF = 2'b00; -//parameter RAMP_UP = 2'b01; -//parameter LED_ON = 2'b10; -//parameter RAMP_DOWN = 2'b11; -//parameter on_max_cnt = 28'h16E35ED; // 1 sec steady -//parameter [3:0] Brightness=4'b0111; //50% Brightness -//parameter [3:0] BreatheRamp=4'b0110; //2x -//parameter [3:0] BlinkRate=4'b0101; //1sec -//parameter string RGB0_CURRENT = "0b111111"; -//parameter string RGB1_CURRENT = "0b111111"; -//parameter string RGB2_CURRENT = "0b111111"; -defparam U1.on_hi = 2'b10; -defparam U1.on_lo = 2'b01; -defparam U1.off = 2'b00; -defparam U1.LED_OFF = 2'b00; -defparam U1.RAMP_UP = 2'b01; -defparam U1.LED_ON = 2'b10; -defparam U1.RAMP_DOWN = 2'b11; -defparam U1.on_max_cnt = 28'h16E35ED; // 1 sec steady -defparam U1.Brightness = 4'b0111; // 50% Brightness -defparam U1.BreatheRamp = 4'b0110; // 2x -defparam U1.BlinkRate = 4'b0101; // 1 sec -defparam U2.RGB0_CURRENT = "0b111111"; -defparam U2.RGB1_CURRENT = "0b111111"; -defparam U2.RGB2_CURRENT = "0b111111"; - -LED_control1 U1 (.clk12M(clk12M),.rst(rst),.color_sel(color_sel),.RGB_Blink_En(RGB_Blink_En),.red_pwm(red_pwm),.blu_pwm(blu_pwm),.grn_pwm(grn_pwm)); - - -RGB U2 (.CURREN('b1),.RGB0PWM(blu_pwm),.RGB1PWM(grn_pwm),.RGB2PWM(red_pwm),.RGBLEDEN('b1),.RGB0(BLUn),.RGB1(GRNn),.RGB2(REDn)); - -assign RED = red_pwm; -assign GRN = grn_pwm; -assign BLU = blu_pwm; - -endmodule - - - - - - - - - - - - - - diff --git a/Ampelansteuerung/steuerung.sv b/Ampelansteuerung/steuerung.sv new file mode 100644 index 0000000..de80e6d --- /dev/null +++ b/Ampelansteuerung/steuerung.sv @@ -0,0 +1,63 @@ +module steuerung ( +bus.steuerung_port b, //b.dip[3:0], b.timer, b.clk, b.spi_read[1:0] +led_if.led_port_top i //i.rgb[2:0], i.rgbn[2:0] +); + +//dip[3:2] -> select colour, dip[1] -> read ~ 1/write ~ 0, dip[0] -> on ~ 1/off ~ 0 + +//input wire clk12M, -> b.clk +//input wire rst, -> b.dip[0] +//input wire [1:0] color_sel, -> b.dip[3:2] +//input wire rw, -> b.dip[1] +//output reg REDn, -> i.rgbn[0] +//output reg BLUn, -> i.rgbn[1] +//output reg GRNn, -> i.rgbn[2] +//output reg RED, -> i.rgb[0] +//output reg BLU, -> i.rgb[1] +//output reg GRN -> i.rgb[2] + + +wire red_pwm; +wire grn_pwm; +wire blu_pwm; + + +defparam U1.on_hi = 2'b10; +defparam U1.on_lo = 2'b01; +defparam U1.off = 2'b00; +defparam U1.LED_OFF = 2'b00; +defparam U1.RAMP_UP = 2'b01; +defparam U1.LED_ON = 2'b10; +defparam U1.RAMP_DOWN = 2'b11; +defparam U1.on_max_cnt = 28'h16E35ED; // 1 sec steady +defparam U1.Brightness = 4'b0111; // 50% Brightness +defparam U1.BreatheRamp = 4'b0110; // 2x +defparam U1.BlinkRate = 4'b0101; // 1 sec +defparam U2.RGB0_CURRENT = "0b111111"; +defparam U2.RGB1_CURRENT = "0b111111"; +defparam U2.RGB2_CURRENT = "0b111111"; + +LED_control1 U1 (.clk12M(b.clk),.rst(b.dip[0]),.color_sel(b.dip[3:2]),.rw(b.dip[1]),.red_pwm(red_pwm),.blu_pwm(blu_pwm),.grn_pwm(grn_pwm)); + + +RGB U2 (.CURREN('b1),.RGB0PWM(blu_pwm),.RGB1PWM(grn_pwm),.RGB2PWM(red_pwm),.RGBLEDEN('b1),.RGB0(i.rgbn[1]),.RGB1(i.rgbn[2]),.RGB2(rgbn[0])); + +assign i.rgb[0] = red_pwm; +assign i.rgb[2] = grn_pwm; +assign i.rgb[1] = blu_pwm; + +endmodule + + + + + + + + + + + + + + diff --git a/Ampelansteuerung/testbench.sv b/Ampelansteuerung/testbench.sv deleted file mode 100644 index 10c83b5..0000000 --- a/Ampelansteuerung/testbench.sv +++ /dev/null @@ -1,130 +0,0 @@ -// ================================================================== -// >>>>>>>>>>>>>>>>>>>>>>> COPYRIGHT NOTICE <<<<<<<<<<<<<<<<<<<<<<<<< -// ------------------------------------------------------------------ -// Copyright (c) 2017 by Lattice Semiconductor Corporation -// ALL RIGHTS RESERVED -// ------------------------------------------------------------------ -// -// Permission: -// -// Lattice SG Pte. Ltd. grants permission to use this code -// pursuant to the terms of the Lattice Reference Design License Agreement. -// -// -// Disclaimer: -// -// This VHDL or Verilog source code is intended as a design reference -// which illustrates how these types of functions can be implemented. -// It is the user's responsibility to verify their design for -// consistency and functionality through the use of formal -// verification methods. Lattice provides no warranty -// regarding the use or functionality of this code. -// -// -------------------------------------------------------------------- -// -// Lattice SG Pte. Lt++++++++++++++++d. -// 101 Thomson Road, United Square #07-02 -// Singapore 307591 -// -// -// TEL: 1-800-Lattice (USA and Canada) -// +65-6631-2000 (Singapore) -// +1-503-268-8001 (other locations) -// -// web: http://www.latticesemi.com/ -// email: techsupport@latticesemi.com -// -// -------------------------------------------------------------------- -// -// Project: iCE5UP 5K RGB LED Tutorial -// File: testbench.v -// Title: LED PWM control -// Description: Creates RGB PWM per control inputs -// -// -// -------------------------------------------------------------------- -// -//------------------------------------------------------------ -// Notes: -// -// -//------------------------------------------------------------ -// Development History: -// -// __DATE__ _BY_ _REV_ _DESCRIPTION___________________________ -// 04/05/17 RK 1.0 Initial tutorial design for Lattice Radiant -// -//------------------------------------------------------------ -// Dependencies: -// -// -// -//------------------------------------------------------------ - - - -//------------------------------------------------------------ -// -// -// Testbench -// -//------------------------------------------------------------ -`timescale 1ns/1ps -module tb; - -//GSR GSR_INST ( .GSR(1)); -//PUR PUR_INST ( .PUR(1)); - - - -reg clk12M; -reg rst; -reg [1:0]color_sel; -reg RGB_Blink_En; -wire REDn; -wire BLUn; -wire GRNn; -wire RED; -wire BLU; -wire GRN; - -led_top dut(.clk12M(clk12M), - .rst(rst), - .color_sel(color_sel), - .RGB_Blink_En(RGB_Blink_En), - .REDn(REDn), - .BLUn(BLUn), - .GRNn(GRNn), - .RED(RED), - .BLU(BLU), - .GRN(GRN) - ); - -initial -begin - clk12M=1'b0; -end - -always - #41.666666 clk12M=~clk12M; //clock generation - - - initial - begin - rst=1'b1; - color_sel=2'b01; - RGB_Blink_En=1'b0; - #1000 - rst=1'b0; - #3000000 - color_sel=2'b11; - #3000000 - $stop; - end - - initial - begin - $monitor("time=%t,RGB_Blink_En=%d,rst=%d,color_sel=%2d, REDn=%d, BLUn=%d, GRNn=%d",$time,RGB_Blink_En,rst,color_sel,REDn,BLUn,GRNn); - end - -endmodule \ No newline at end of file