Merge branch 'counter-extraction' of github.com:azonenberg/yosys into counter-extraction

This commit is contained in:
Andrew Zonenberg 2017-08-30 18:16:15 -07:00
commit 16043b79b6
3 changed files with 56 additions and 36 deletions

View File

@ -234,6 +234,22 @@ pool<string> RTLIL::AttrObject::get_strpool_attribute(RTLIL::IdString id) const
return data; return data;
} }
void RTLIL::AttrObject::set_src_attribute(const std::string &src)
{
if (src.empty())
attributes.erase("\\src");
else
attributes["\\src"] = src;
}
std::string RTLIL::AttrObject::get_src_attribute() const
{
std::string src;
if (attributes.count("\\src"))
src = attributes.at("\\src").decode_string();
return src;
}
bool RTLIL::Selection::selected_module(RTLIL::IdString mod_name) const bool RTLIL::Selection::selected_module(RTLIL::IdString mod_name) const
{ {
if (full_selection) if (full_selection)

View File

@ -505,9 +505,13 @@ struct RTLIL::AttrObject
void set_bool_attribute(RTLIL::IdString id); void set_bool_attribute(RTLIL::IdString id);
bool get_bool_attribute(RTLIL::IdString id) const; bool get_bool_attribute(RTLIL::IdString id) const;
void set_strpool_attribute(RTLIL::IdString id, const pool<string> &data); void set_strpool_attribute(RTLIL::IdString id, const pool<string> &data);
void add_strpool_attribute(RTLIL::IdString id, const pool<string> &data); void add_strpool_attribute(RTLIL::IdString id, const pool<string> &data);
pool<string> get_strpool_attribute(RTLIL::IdString id) const; pool<string> get_strpool_attribute(RTLIL::IdString id) const;
void set_src_attribute(const std::string &src);
std::string get_src_attribute() const;
}; };
struct RTLIL::SigChunk struct RTLIL::SigChunk

View File

@ -147,7 +147,15 @@ module GP_COUNT14_ADV(input CLK, input RST, output reg OUT,
"RISING": begin "RISING": begin
always @(posedge CLK, posedge RST) begin always @(posedge CLK, posedge RST) begin
if(KEEP) begin //Resets
if(RST) begin
if(RESET_VALUE == "ZERO")
count <= 0;
else
count <= COUNT_TO;
end
else if(KEEP) begin
end end
else if(UP) begin else if(UP) begin
count <= count + 1'd1; count <= count + 1'd1;
@ -161,21 +169,21 @@ module GP_COUNT14_ADV(input CLK, input RST, output reg OUT,
count <= COUNT_TO; count <= COUNT_TO;
end end
//Resets
if(RST) begin
if(RESET_VALUE == "ZERO")
count <= 0;
else
count <= COUNT_TO;
end
end end
end end
"FALLING": begin "FALLING": begin
always @(posedge CLK, negedge RST) begin always @(posedge CLK, negedge RST) begin
if(KEEP) begin //Resets
if(!RST) begin
if(RESET_VALUE == "ZERO")
count <= 0;
else
count <= COUNT_TO;
end
else if(KEEP) begin
end end
else if(UP) begin else if(UP) begin
count <= count + 1'd1; count <= count + 1'd1;
@ -189,14 +197,6 @@ module GP_COUNT14_ADV(input CLK, input RST, output reg OUT,
count <= COUNT_TO; count <= COUNT_TO;
end end
//Resets
if(!RST) begin
if(RESET_VALUE == "ZERO")
count <= 0;
else
count <= COUNT_TO;
end
end end
end end
@ -286,8 +286,16 @@ module GP_COUNT8_ADV(input CLK, input RST, output reg OUT,
"RISING": begin "RISING": begin
always @(posedge CLK, posedge RST) begin always @(posedge CLK, posedge RST) begin
//Resets
if(RST) begin
if(RESET_VALUE == "ZERO")
count <= 0;
else
count <= COUNT_TO;
end
//Main counter //Main counter
if(KEEP) begin else if(KEEP) begin
end end
else if(UP) begin else if(UP) begin
count <= count + 1'd1; count <= count + 1'd1;
@ -301,22 +309,22 @@ module GP_COUNT8_ADV(input CLK, input RST, output reg OUT,
count <= COUNT_TO; count <= COUNT_TO;
end end
//Resets
if(RST) begin
if(RESET_VALUE == "ZERO")
count <= 0;
else
count <= COUNT_TO;
end
end end
end end
"FALLING": begin "FALLING": begin
always @(posedge CLK, negedge RST) begin always @(posedge CLK, negedge RST) begin
//Resets
if(!RST) begin
if(RESET_VALUE == "ZERO")
count <= 0;
else
count <= COUNT_TO;
end
//Main counter //Main counter
if(KEEP) begin else if(KEEP) begin
end end
else if(UP) begin else if(UP) begin
count <= count + 1'd1; count <= count + 1'd1;
@ -330,14 +338,6 @@ module GP_COUNT8_ADV(input CLK, input RST, output reg OUT,
count <= COUNT_TO; count <= COUNT_TO;
end end
//Resets
if(!RST) begin
if(RESET_VALUE == "ZERO")
count <= 0;
else
count <= COUNT_TO;
end
end end
end end