bool output_syntax(char *argv[], evl_module &module, evl_wires &wires, evl_components &components, evl_endmodule &endmodule)
{


	std::string output_file_name = std::string(argv[1]) + ".syntax";
	std::ofstream output_file(output_file_name.c_str());
	if (!output_file)
	{
		std::cerr << "I can't write " << argv[1] << ".tokens ." << std::endl;
		return false;
	}

	if (!module.type.empty())//if .evl has a module, output its name
	{
		output_file << "module " << module.type << std::endl;
	}

	if (!wires.empty())//if .evl has wires, output names
	{
		output_file << "wires " << wires.size() << std::endl;
		for (evl_wires::iterator i = wires.begin(); i != wires.end(); ++i)
		{
			evl_wire	wire = *i;
			output_file << "  wire " << wire.name << " " << wire.width << std::endl;
		}
	}

	if (!components.empty())//if .evl has components, output pins, types and names
	{
		output_file << "components " << components.size() << std::endl;
		for (evl_components::iterator i = components.begin(); i != components.end(); ++i)
		{
			evl_component	component = *i;
			output_file << "  component " << component.type << " ";
			if (component.name != "")// component name is optional
				output_file << component.name << " ";
			output_file << component.pins.size() << std::endl;
			for (evl_pins::iterator j = component.pins.begin(); j != component.pins.end(); ++j)
			{
				evl_pin	pin = *j;
				output_file << "    pin " << pin.name;
				if (pin.bus_msb >= 0)
				{
					output_file << " " << pin.bus_msb;
				}
				if (pin.bus_lsb >= 0)
				{
					output_file << " " << pin.bus_lsb;
				}
				output_file << std::endl;
			}
		}
	}

	if (!endmodule.name.empty())//if .evl has endmodule, output it
	{
		output_file << "endmodule" << std::endl;
	}
	return true;
}
evl_wires_table make_wires_table(const evl_wires &wires)
{
    evl_wires_table wires_table;
    
    for (evl_wires::const_iterator it = wires.begin();
         it != wires.end(); ++it)
    {
        std::pair<std::string, int>  _pair=std::make_pair(it->name, it->width);
        wires_table.insert(_pair);
    }
    
    return wires_table;
}
示例#3
0
bool netlist::create_nets(const evl_wires &wires) {
	for (evl_wires::const_iterator iter = wires.begin();
			iter != wires.end(); ++iter) {
		if ((*iter).width == 1) {
			create_net((*iter).name);
		}
		else {
			for (int i = 0; i < (*iter).width; ++i) {
				create_net(make_net_name((*iter).name, i));
			}
		}
	}
	return true;
}
bool netlist::create_nets(const evl_wires &wires)
{
    for(evl_wires::const_iterator w=wires.begin(); w!=wires.end();++w)
    {
        if (w->width == 1)
        {
            create_net(w->name);
        }
        else
        {
            for (int i = 0; i < w->width; ++i)
            {
                std::string	net_name = make_net_name(w->name, i);
                create_net(net_name);
            }
        }
    }
    return	true;
}