FPGARelated.com
Forums

cout in FPGA

Started by WCH 2 years ago1 replylatest reply 2 years ago85 views

Hello, I am new to FPGA. I have seen a template in DE0-nano. I would like to display the value in "PWM_width <= PWM_width[5:0]+ PWM_adj;" one by one in a screen like the cout function in C++

I used "%display()" but I didn't see the value in the message box in quartus. Thanks

/

module DE0_NANO(

//////////// CLOCK //////////

CLOCK_50,

//////////// LED //////////

LED,

//////////// KEY //////////

KEY,

//////////// SW //////////

SW,

//////////// SDRAM //////////

DRAM_ADDR,

DRAM_BA,

DRAM_CAS_N,

DRAM_CKE,

DRAM_CLK,

DRAM_CS_N,

DRAM_DQ,

DRAM_DQM,

DRAM_RAS_N,

DRAM_WE_N,

//////////// EPCS //////////

EPCS_ASDO,

EPCS_DATA0,

EPCS_DCLK,

EPCS_NCSO,

//////////// Accelerometer and EEPROM //////////

G_SENSOR_CS_N,

G_SENSOR_INT,

I2C_SCLK,

I2C_SDAT,

//////////// ADC //////////

ADC_CS_N,

ADC_SADDR,

ADC_SCLK,

ADC_SDAT,

//////////// 2x13 GPIO Header //////////

GPIO_2,

GPIO_2_IN,

//////////// GPIO_0, GPIO_0 connect to GPIO Default //////////

GPIO_0_D,

GPIO_0_IN,

//////////// GPIO_0, GPIO_1 connect to GPIO Default //////////

GPIO_1_D,

GPIO_1_IN,

);

//=======================================================

//  PARAMETER declarations

//=======================================================

//=======================================================

//  PORT declarations

//=======================================================

//////////// CLOCK //////////

input           CLOCK_50;

//////////// LED //////////

output     [7:0]LED;

//////////// KEY //////////

input      [1:0]KEY;

//////////// SW //////////

input      [3:0]SW;

//////////// SDRAM //////////

output    [12:0]DRAM_ADDR;

output     [1:0]DRAM_BA;

output          DRAM_CAS_N;

output          DRAM_CKE;

output          DRAM_CLK;

output          DRAM_CS_N;

inout     [15:0]DRAM_DQ;

output     [1:0]DRAM_DQM;

output          DRAM_RAS_N;

output          DRAM_WE_N;

//////////// EPCS //////////

output          EPCS_ASDO;

input           EPCS_DATA0;

output          EPCS_DCLK;

output          EPCS_NCSO;

//////////// Accelerometer and EEPROM //////////

output          G_SENSOR_CS_N;

input           G_SENSOR_INT;

output          I2C_SCLK;

inout           I2C_SDAT;

//////////// ADC //////////

output          ADC_CS_N;

output          ADC_SADDR;

output          ADC_SCLK;

input           ADC_SDAT;

//////////// 2x13 GPIO Header //////////

inout     [12:0]GPIO_2;

input      [2:0]GPIO_2_IN;

//////////// GPIO_0, GPIO_0 connect to GPIO Default //////////

inout     [33:0]GPIO_0_D;

input      [1:0]GPIO_0_IN;

//////////// GPIO_0, GPIO_1 connect to GPIO Default //////////

inout     [33:0]GPIO_1_D;

input      [1:0]GPIO_1_IN;

//=======================================================

//  REG/WIRE declarations

//=======================================================

wire           reset_n;

reg [26:0] counter;

reg [5:0]   PWM_adj;

reg     [6:0]   PWM_width;

reg     [7:0]   LED;

//=======================================================

//  Structural coding

//=======================================================

assign   reset_n = KEY[0];

always @(posedge CLOCK_50 or negedge reset_n)

begin

if(!reset_n)

begin

counter <= 0;

LED[0] <= 0;

end

else begin

counter   <= counter+1;

PWM_width <= PWM_width[5:0]+ PWM_adj;

if(counter[26])

begin

PWM_adj <= counter[25:20];

end

else begin

PWM_adj <= ~ counter[25:20];

end

LED[0] <= ~PWM_width[6];

LED[1] <= ~PWM_width[6];

LED[2] <= ~PWM_width[6];

LED[3] <= ~PWM_width[6];

LED[4] <= PWM_width[6];

LED[5] <= PWM_width[6];

LED[6] <= PWM_width[6];

LED[7] <= PWM_width[6];

end

end

endmodule

[ - ]
Reply by PtorruApril 1, 2022

Hi WCH, have you found any guidance since your post?